/**
 * Created by shudong.msd(风骐) on 2016/4/25.
 */

app.service('datepickerService',function(){

    this.callDatePicker = function(ele){
        //时间
        ele.datepicker({
            format: 'yyyy-mm-dd',
            language: 'zh-CN',
            autoclose:true,
            minView:2,
            keyboardNavigation:true,
//            calendarWeeks:true,
            endDate:'0d',
            immediateUpdates:true,
            orientation:"bottom auto",
            todayHighlight:true,
            weekStart:1,
            fqInputs: ele,
            arrowTemplates: {
                leftArrow: '<b class="fa fa-long-arrow-left">&lt;</b>',
                rightArrow: '<b class="fa fa-long-arrow-left">&gt;</b>'
            }
        }).on('hide', function(e) {
            if($(this).attr('data-fq-role')=='start'){
                $('.datepicker-focus-start').hide();
            }else{
                $('.datepicker-focus-end').hide();
            }
        }).on('show',function(e){
            if($(this).attr('data-fq-role')=='start'){
                var that =  $('.datepicker-focus-start');
                if($(this).val().indexOf('~')>=0){
                    that.css('width',150);
                    that.css('left',95);
                }else{
                    that.css('width',100);
                    that.css('left',122);
                }
                that.show();
            }else{
                var that =  $('.datepicker-focus-end');
                if($(this).val().indexOf('~')>=0){
                    that.css('width',150);
                    that.css('left',455);
                }else{
                    that.css('width',100);
                    that.css('left',482);
                }
                that.show();
            }

        });
    };


});